/**
 * 
 */
package design_pattern.template.bank;

/**
 * @author linzq
 * 
 */
public abstract class Account {

  protected String accountNumber;

  public Account() {
    accountNumber = null;
  }

  public Account(String accountNumber) {
    this.accountNumber = accountNumber;
  }

  final public double calcInterest() {
    String accountType = doGetAccountType();
    double interestRate = doCalcInterestRate(accountType);
    double amount = doGetAmount(accountType, accountNumber);
    return amount * interestRate;
  }

  /**
   * @param accountType
   * @param accountNumber2
   * @return
   */
  protected abstract double doGetAmount(String accountType, String accountNumber);

  /**
   * @return
   */
  protected abstract String doGetAccountType();

  /**
   * @return
   */
  protected abstract double doCalcInterestRate(String accountType);
}
